Field of the Invention
The invention relates in general to a storage unit of an embedded device and a method of accessing the storage unit, and more particularly, to a RAM disk of an embedded device and a method of accessing the RAM disk.
Description of the Related Art
Generally speaking, an embedded system frequently adopts a processor with lower performance, a smaller system memory and a smaller storage unit in order to be cost-effective. With such limited hardware resources, designers strive to fully utilize various resources. One embedded device usually includes a system memory that can be directly accessed by a processor, and a module memory (i.e., hardware IP memory) exclusive to a predetermined function module of the embedded system. For example, the system memory is a dynamic random access memory (DRAM). For example, in a smart television, the processor accesses program codes and data in the system memory to execute an operating system of the smart television, whereas a demodulation module (i.e., the above function module) includes an exclusive module memory for storing program codes that the demodulation module requires when executing the demodulation function. The module memory is exclusive to the dedicated function module, and cannot be directly accessed by the processor. When the demodulation module is in an idle state (e.g., when the smart television is used to browse web pages), the module memory is in equivalence wasted.
Some embedded systems utilize a so-called RAM disk technology to simulate an additional storage space from an idle memory to fully utilize system resources. Assuming that an embedded system includes an idle first function module (that accesses a first module memory to complete its function) and a second function module (that accesses a second module memory to complete its function), a RAM disk driving module of the embedded system respectively simulates a first RAM disk and a second RAM disk from the first module memory and the second module memory, and mounts the simulated first and second RAM disks to an operating system of the embedded system to increase system resources. For example, when the system memory is insufficient, the operating system may swap a process that is not being executed to the RAM disk to spare more system memory for processes that are being executed. The RAM disk driving module executes one driver on each of the first RAM disk and the second RAM disk. Each of the drivers includes a page table for managing the corresponding RAM disk, and so the RAM disk driving module includes a first page table corresponding to the first RAM disk and a second page table corresponding to the second RAM disk. However, the above storage method suffers from following drawbacks. First of all, the storage space cannot be utilized in an integrated manner, such that fragmented storage blocks in each of the RAM disks cannot be efficiently utilized. Secondly, when the function module enters a working state from an idle state, the RAM disk simulated from the corresponding module memory needs to be unmounted from the operating system; when the function module again returns to an idle state, the operating system needs to re-mount the corresponding RAM disk, leading to unsatisfactory execution efficiency. Thirdly, in the event that the RAM disk storages compressed system memory data, the unmounting process of the RAM disk needs decompress the compressed data into decompressed data and temporarily store the decompressed data to the system memory (as the system memory cannot store compressed data), and then compress the data and store the compressed data to another RAM disk. With a limited system memory, temporarily storing the decompressed data to the system memory may cause a large impact on the system memory, and may even lead to out of memory (OOM) situations for the operating system in more severe cases.